package com.happy.second.Config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @author itoutsource.cz10
 */
@Configuration
public class DataConfig {

    @Primary
    @Bean(name = "ynnData")
    @Qualifier(value = "ynnData")
    @ConfigurationProperties(prefix = "spring.datasource.db1")
    public DataSource ynnDataSource(){
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "qlpData")
    @Qualifier(value = "qlpData")
    @ConfigurationProperties(prefix = "spring.datasource.db2")
    public DataSource qlpDataSource(){
        return DataSourceBuilder.create().build();
    }
}
